package Test;

public class Test06 {

	public static void main(String[] args) {
		/**统计字符

		  * 字符数组：{'a','l','f','m','f','o','b','b','s','n'}
		  * 定义printCount方法，统计每个字符出现的次数并打印到控制台。*/
		char[] ch = {'a','l','f','m','f','o','b','b','s','n'}; 
		
		printCount(ch);

	}
	
	public static void printCount(char[] c){
		int count = 0;
		for(int i = 0; i < c.length; i++){
			for(int j = 0 ; j < c.length ; j++){
				if(c[i] == c[j]){ 
					count++;	
				}	
			}
			System.out.println(c[i] + "共出现" + count + "次");
			count = 0; //输出后将统计count变量清零 不然count一直叠加
		}
	}

}
